﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ICM_MAS_Contacts.aspx.cs" Inherits="KPIS.GERP.GFMS.APP.App_UI.Forms.ICM_MAS_Contacts" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

    <script src="../../js/jquery-1.9.1.js" type="text/javascript"></script>
    <script src="../../js/jquery-ui-1.10.3.custom.js" type="text/javascript"></script>
    <script src="../../js/jquery-ui-1.10.3.custom.min.js"></script>
    <%--<script src="../../js/jquery-1.8.3.js" type="text/javascript"></script>--%>
    <link href="../../css/jquery-ui-1.10.3.custom.css" rel="stylesheet" type="text/javascript"/>
     <link href="../../css/jquery.ui.theme.css" rel="stylesheet" type="text/javascript"/>
    <link href="../../css/jquery-ui.css" rel="stylesheet"/>
    <Script Language="JavaScript">
        function base64_encode(data) {
            var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
            var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
              ac = 0,
              enc = "",
              tmp_arr = [];

            if (!data) {
                return data;
            }

            do { // pack three octets into four hexets
                o1 = data.charCodeAt(i++);
                o2 = data.charCodeAt(i++);
                o3 = data.charCodeAt(i++);

                bits = o1 << 16 | o2 << 8 | o3;

                h1 = bits >> 18 & 0x3f;
                h2 = bits >> 12 & 0x3f;
                h3 = bits >> 6 & 0x3f;
                h4 = bits & 0x3f;

                // use hexets to index into b64, and append result to encoded string
                tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
            } while (i < data.length);

            enc = tmp_arr.join('');

            var r = data.length % 3;

            return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);
        }

        function base64_decode(data) {
            var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
            var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
              ac = 0,
              dec = "",
              tmp_arr = [];

            if (!data) {
                return data;
            }

            data += '';

            do { // unpack four hexets into three octets using index points in b64
                h1 = b64.indexOf(data.charAt(i++));
                h2 = b64.indexOf(data.charAt(i++));
                h3 = b64.indexOf(data.charAt(i++));
                h4 = b64.indexOf(data.charAt(i++));

                bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;

                o1 = bits >> 16 & 0xff;
                o2 = bits >> 8 & 0xff;
                o3 = bits & 0xff;

                if (h3 == 64) {
                    tmp_arr[ac++] = String.fromCharCode(o1);
                } else if (h4 == 64) {
                    tmp_arr[ac++] = String.fromCharCode(o1, o2);
                } else {
                    tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
                }
            } while (i < data.length);

            dec = tmp_arr.join('');

            return dec;
        }
  </Script>
        <style type="text/css" >
            #frameShow{
             height: 810px;
             width: 920px;
}
              #FRAMELog{
             height: 700px;
             width: 890px;
        }
        </style>
</head>
<body>
    <%--<meta http-equiv="refresh" content="0; url=../Forms/Default.aspx">--%>
   <script type="text/javascript">
                // open Dialog
           $(function () {
               $(".opendialog").click(function () {   //เมื่อมีการคลิก class aa (ปุ่มเราถูกตั้งชื่อ class ว่า dialog)
                   //$("#frame").attr("src", $(this).attr("href"));
                   $("#dialog").dialog("open");  //คลิกปุ่มแล้ว ให้เปิด dialog ขึ้นมาโดยdialog มาจาก <div id="dialog"  ที่โค๊ดด้านล่าง
               });
               // Auto click Dialog
               setTimeout(function () {
                   $('.opendialog').trigger('click');
               }, 1e3);
            // propertise Dialog
            $("#dialog").dialog({
            title: "ข้อมูลผู้ขาย",
            autoOpen: false, 
            height: '810',
            width: '950',
            resizable: false,
            modal: true,
            position: 'fixed',
            show: 'clip',
            hide: 'clip',
            close: function (event, ui) {
                $('#dialog').dialog('close');
                $(location).attr('href', '../Forms/Default.aspx');//redirect to home
            },
            open: function (ev, ui) {
                var url = 'http://' + window.location.host + '<%= ConfigurationSettings.AppSettings["SubSystem"] %>/WEB.GIMS/Home/SingleSigonRawData?' + Authen() + '&redirectPage=' + base64_encode('~/MasContact/Index?Category=2&nolayout=true');
                $('#frameShow').attr('src', url);//go to Web.GIMS
            }

            });
           });
       //get user and pass
           function Authen() {
               var AuthenUser = $('#AuthenUser').html();//Get User
               var AuthenPass = $('#AuthenPass').html();//Get Pass
               var AuthenUrlDb = $('#AuthenUrlDb').html();//Get UrlDb
               var tmp_user, tmp_pass;
               tmp_user = base64_decode(AuthenUser);
               tmp_pass = base64_decode(AuthenPass);
               var encode = 'UserName=' + tmp_user + '&Password=' + tmp_pass;
               return encode;
           }
           function UrlDbname() {
               var AuthenUrlDb = $('#AuthenUrlDb').html();//Get UrlDb
               var encode = base64_decode(AuthenUrlDb);
               return encode;
           }

   </script>

<input class="opendialog" name="opendialog" type="button" value="Dialog" style="display:none" />

<div id="dialog">
        <IFRAME  id="frameShow" SRC="" ></iframe>

</body>
</html>
